<%@ page isErrorPage="true" contentType="text/html;charset=iso8859_1" language="java" %>

<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tld/struts-nested.tld" prefix="nested" %>

<jsp:useBean id="oLogon" class="git.bankview.wl.bean.LogonBean" scope="session" />
<jsp:setProperty name="oLogon" property="remoteHost" value="<%=request.getRemoteAddr()%>" />

<%
	boolean bExcepitonMsgKey = false;
	boolean bCauseMsgKey = false;
	
	if (null == exception) exception = (Exception)request.getAttribute("javax.servlet.error.exception"); 
	String cause = (String)request.getAttribute("javax.servlet.error.message");
	if (null != exception)
	{
		if (exception instanceof git.bankview.wl.common.ResourceBundledObject)
			bExcepitonMsgKey = true;
		
		if (null == exception.getCause())
		{
			cause = exception.getMessage();
			bCauseMsgKey = bExcepitonMsgKey;
		}
		else
		{
			cause = exception.getCause().getMessage();
			if (exception.getCause() instanceof git.bankview.wl.common.ResourceBundledObject)
				bCauseMsgKey = true;
		}
	}
	
	request.setAttribute("request", request);
%>

<html:html locale="true">
<head>
	<meta http-equiv=content-type content="text/html; charset=GBK">
	<title><bean:message key="exception.title" /></title>
	<link rel="stylesheet" href="<%=request.getContextPath() %><html:rewrite href="/style/default_aux.css" />">
	<link rel="stylesheet" href="<%=request.getContextPath() %><html:rewrite href="/style/pp.css" />">
</head>
<body onload="oninit();">
	<script src="<%=request.getContextPath() %><html:rewrite href="/script/overlib.js" />" language="JavaScript"></script>
	<script src="<%=request.getContextPath() %><html:rewrite href="/script/style.js" />" language="JavaScript"></script>
	<script src="<%=request.getContextPath() %><html:rewrite href="/script/windows.js" />" language="JavaScript"></script>
	<table cellspacing="0" class="filledframe">
		<tr>
			<td nowrap="" class="clientframe">
				<table id="oHelp" class="helper" >
					<tr>
						<td width="200" class="label">&nbsp;</td>
						<td class="help"></td>
					</tr>
				</table>
				
				<div class="listtitle"><bean:message key="exception.title" /></div>
				<div class="subtitle" style="width: 560px; "><span class="error"><%
								if (bCauseMsgKey)
								{%><bean:message key="<%=cause%>" /><%}
								else
									out.print(cause);
							%></span></div>
				<table id="oPropPagesTab"></table>
				
				<!---------------- generial information properties page BEGIN ----------------->
				<div id="ppSummary">
					<table width="100%" height="100%" cellspacing="0" class="formpanel">
						<tr><td class="toppad">&nbsp;</td></tr>
						<tr><td class="input"><table cellspacing="0"><tr>
							<td nowrap class="label" style="vertical-align: top; "><bean:message key="exception.cause.label" />:</td>
							<td class="remark"><%
								if (null != exception)
								{
									if (bExcepitonMsgKey)
									{%><bean:message key="<%=exception.getMessage()%>" /><%}
									else
										out.print(exception.getMessage());
								}
								else
								{
									out.print("(Unknown error)");
								}
							%></td>
						</tr></table></td></tr>
						<tr><td class="line">&nbsp;</td></tr>
						<tr><td class="input"><table cellspacing="0"><tr>
							<td nowrap class="label" style="vertical-align: top; "><bean:message key="exception.suggest.label" />:</td>
							<td class="remark"><bean:message key="exception.suggest.content1" /><br>
								<bean:message key="exception.suggest.content2" /><br>
								<bean:message key="exception.suggest.content3" />
								</td>
						</tr></table></td></tr>
<%
	if (!oLogon.getLogon())
	{
%>
						<tr><td class="line"><hr></td></tr>
						<tr><td class="input"><table cellspacing="0"><tr>
							<td nowrap class="label"><bean:message key="common.userid" />:</td>
							<td nowrap ><input type="text" id="oUsername" size="20" maxlength="16" class="text" onkeydown="return focusMove()" onfocus="onFieldFocus()" onblur="onFieldBlur()" tabindex="101" ></td>
						</tr></table></td></tr>
						<tr><td class="input"><table cellspacing="0"><tr>
							<td nowrap class="label"><bean:message key="common.password" />:</td>
							<td nowrap ><input type="password" id="oPassword" size="20" maxlength="16" class="text" onfocus="onFieldFocus()" onblur="onFieldBlur()" tabindex="102" ></td>
						</tr></table></td></tr>
<%
	}
%>
						<tr><td class="line"><table cellspacing="0"><tr>
							<td nowrap class="label"><span class="error" id="oErrMsg"></span></td>
						</tr></table></td></tr>
						<tr><td class="bottompad">&nbsp;</td></tr>
					</table>
				</div>
				<!---------------- generial information properties page END ----------------->

				<!---------------- remark properties page BEGIN ----------------->
				<div id="ppDetail">
					<table width="100%" height="100%" cellspacing="0" class="formpanel">
						<tr><td class="toppad">&nbsp;</td></tr>
						<tr><td class="input"><table cellspacing="0"><tr>
							<td nowrap >
								<textarea readonly cols="75" rows="16" tabindex="601"><% if (null != exception) exception.printStackTrace(new java.io.PrintWriter(out)); %></textarea></td>
						</tr></table></td></tr>
						<tr><td class="bottompad">&nbsp;</td></tr>
					</table>
				</div>
				<!---------------- remark properties page END ----------------->
				
				<table width="600" class="formpanelbar">
					<tr>
						<td align="right" nowrap="">
<%
	if (!oLogon.getLogon())
	{
%>
							<input type="button" tabindex="1001" onclick="onLogin();" class="button" value="<bean:message key="common.login" />" >
<%
	}
%>
							<input type="button" tabindex="1001" onclick="onRetry();" class="button" value="<bean:message key="common.retry" />" ></td>
					</tr>
				</table>
			</td>
			<!-- td id="oFrame" nowrap="" class="infoframe">&nbsp;</td -->
		</tr>
	</table>
	
	<form action="<%=request.getContextPath()%>/jsp/auth/relogin.jsp" id="oLoginForm" method="post" target="oLogonFrame">
		<input type="hidden" name="username" >
		<input type="hidden" name="password" >
		<input type="hidden" name="successCallback" value="onRetry" >
		<input type="hidden" name="failCallback" value="onFailLogin" >
	</form>
	<iframe id="oLogonFrame" style="display: none; " name="oLogonFrame" ></iframe>
	
<script language="javascript">
function oninit()
{
	initPropertyPageTable(oPropPagesTab, 600, 320);
	addPropertyPage(oPropPagesTab, ppSummary, "<bean:message key="exception.pp.summary" />");
	addPropertyPage(oPropPagesTab, ppDetail, "<bean:message key="exception.pp.detail" />");
	setPropertyPageActive(oPropPagesTab, 0);
	if (undefined != parent && undefined != parent.onFault)
	{
		parent.onFault("<%=cause%>");
	}
}
function onLogin()
{
	if (0 == oUsername.value.length)
	{
		alert("<bean:message key="logon.err.noUsername" />");
	}
	else if (0 == oPassword.length)
	{
		alert("<bean:message key="logon.err.noPassword" />");
	}
	else
	{
		//alert(oUsername.value);
		//alert(oPassword.value);
		oLoginForm.username.value = oUsername.value;
		oLoginForm.password.value = oPassword.value;
		oLoginForm.submit();
	}
}
function onRetry()
{
<%
	String redirect = request.getParameter("redirect");
	if (null == redirect)
	{
%>location.reload(); //= "<html:rewrite href="<%=request.getRequestURL().toString()%>" name="request" property="parameterMap" />";
<%
	}
	else
	{
%>location = "<%=redirect%>";
<%
	}
%>
}
function onFailLogin(msg)
{
	oUsername.value = "";
	oPassword.value = "";
	oErrMsg.innerText = msg;
}
</script>

</body>
</html:html>
